var context = {intervals: [], timeouts: []};
(function () {
    var baseUrl = "../", jQueryFile = 'jquery-3.1.0.min',
        urlArgs = "";
    //"v=1-" + (new Date()).getTime();
    context.path = "";

    context.simpleCall = function (config, ids, factory) {
        if (typeof ids === "function") {
            factory = ids;
            ids = config;
            config = null;
        }

        require.config({
            urlArgs: urlArgs,
            baseUrl: baseUrl,
            waitSeconds: 0,
            map: {
                '*': {
                    'css': 'assets/plugins/amd/css'
                }
            },
            paths: {
                // plugins
                jquery: [
                    "assets/plugins/jQuery/" + jQueryFile
                ],
                jQuery: [
                    "assets/plugins/jQuery/" + jQueryFile
                ],
                bootstrap: [
                    "assets/plugins/bootstrap/js/bootstrap.min"
                ],
                angular: [
                    "assets/plugins/angularjs/angular.min"
                ],
                'angular-route': [
                    "assets/plugins/angularjs/angular-route"
                ]
            },
            shim: {
                bootstrap: {
                    deps: ["jQuery"],
                    exports: "bootstrap"
                },
                jQueryUI: {
                    deps: ["jQuery"],
                    exports: "jQueryUI"
                },
                angular: {
                    deps: ["jQuery", "bootstrap"],
                    exports: "angular"
                },
                'angular-route': {
                    deps: ["angular"],
                    exports: 'ngRouteModule'
                }

            }
        });
        config && require.config(config);
        require(ids, factory);
    };

    context.call = function (config, ids, factory, options) {
        if (typeof ids === "function") {
            factory = ids;
            ids = config;
            config = null;
        }

        initConfig();
        config && require.config(config);
        require(ids, factory);
    };

    function initConfig() {
        require.config({
            urlArgs: urlArgs,
            baseUrl: baseUrl,
            waitSeconds: 0,
            map: {
                '*': {
                    'css': 'assets/plugins/amd/css'
                }
            },
            paths: {
                // Plugins
                jQuery: [
                    "assets/plugins/jQuery/" + jQueryFile
                ],
                jquery: [
                    "assets/plugins/jQuery/" + jQueryFile
                ],
                bootstrap: [
                    "assets/plugins/bootstrap/js/bootstrap.min"
                ],
                angular: [
                    "assets/plugins/angularjs/angular.min"
                ],
                'angular-route': [
                    "assets/plugins/angularjs/angular-route"
                ],
                sanitize: [
                    "assets/plugins/angularjs/sanitize"
                ],
                moment: [
                    "assets/plugins/moment/moment"
                ],
                Jets: [
                    "assets/plugins/jets/jets"
                ],
                datepickerZh: [
                    "assets/plugins/bootstrap-datepicker/locales/bootstrap-datepicker.zh-CN.min"
                ],
                datepicker: [
                    "assets/plugins/bootstrap-datepicker/js/bootstrap-datepicker"
                ],
                dateRangePicker: [
                    "assets/plugins/bootstrap-daterangepicker/daterangepicker"
                ],
                dataTables: [
                    // "assets/plugins/datatables/datatables"
                    "assets/plugins/datatables/jquery.dataTables"
                ],
                validator: [
                    "assets/plugins/bootstrap-validator/validator"
                    // "assets/plugins/bootstrap-validator/validator.min"
                ],
                bootstrapNotify: [
                    "assets/plugins/bootstrap-notify/bootstrap-notify"
                ],
                switcher: [
                    "assets/plugins/bootstrap-switch/js/bootstrap-switch"
                ],
                'bootstrap-dialog': [
                    "assets/plugins/bootstrap-dialog/js/bootstrap-dialog"
                    // "assets/plugins/bootstrap-dialog/js/bootstrap-dialog.min"
                ],
                popover: [
                    "assets/plugins/bootstrap-popover/popover"
                ],
                jQueryUI: [
                    "assets/plugins/jQueryUI/jquery-ui.min"
                ],
                jQueryDragSort: [
                    "assets/plugins/jquery-dragsort/jquery.dragsort-0.5.2.min"
                ],
                jQueryFancyTree: [
                    // "assets/plugins/fancytree/jquery.fancytree-all.min"
                    "assets/plugins/fancytree/jquery.fancytree-all.min"
                ],
                jQueryBootstrapWizard: [
                    "assets/plugins/bootstrap-wizard/jquery.bootstrap.wizard"
                ],
                d3: [
                    "assets/plugins/d3/d3.min"
                ],
                iCheck: [
                    "assets/plugins/iCheck/icheck.min"
                ],
                select2: [
                    "assets/plugins/select2/js/select2.full"
                    // "assets/plugins/select2/js/select2.full.min"
                ],
                sparkline: [
                    "assets/plugins/sparkline/jquery.sparkline.min"
                ],
                echarts: [
                    "assets/plugins/echarts/echarts.min"
                ],
                echartsTheme: [
                    "assets/plugins/echarts/theme/fusion"
                ],
                jsbeautify: [
                    "assets/plugins/jsbeautify/beautify"
                ],
                codemirror: [
                    "assets/plugins/codemirror/codemirror"
                ],
                codemirrorJs: [
                    "assets/plugins/codemirror/javascript"
                ],
                codemirrorClike: [
                    "assets/plugins/codemirror/clike"
                ],
                codemirrorSql: [
                    "assets/plugins/codemirror/sql"
                ],
                codemirrorXml: [
                    "assets/plugins/codemirror/xml"
                ],
                inputmask: [
                    "assets/plugins/inputmask/jquery.inputmask.bundle.min"
                ],
                //jsPlumb
                jsPlumb: [
                    "assets/plugins/jsPlumb/js/jsPlumb-2.0.7"
                ],
                jsPlumbToolkit: [
                    "assets/plugins/jsPlumb/js/jsPlumbToolkit-1.0.19"
                ],
                jsPlumbToolkitAngular: [
                    "assets/plugins/jsPlumb/js/jsPlumbToolkit-angular-1.0.19"
                ],
                treetable: [
                    "assets/plugins/treetable/js/jquery.treetable"
                ],
                ztree: [
                    "assets/plugins/ztree/js/jquery.ztree.core.min"
                ],
                // Plugins end
                // Modules
                // core modules
                core: [
                    "assets/modules/core/js/core"
                ],
                tools: [
                    "assets/modules/core/js/tools"
                ],
                menu: [
                    "assets/modules/core/js/menu"
                ],
                list: [
                    "assets/modules/core/js/list"
                ],
                scanSelect: [
                    "assets/modules/core/js/scan/scanSelect"
                ],
                joint: [
                    "assets/modules/lineage/js/joint"
                ],
                lineage: [
                    "assets/modules/lineage/js/lineage"
                ],
                lineageDb: [
                    "assets/modules/lineage/js/lineage-db"
                ],
                resource: [
                    "assets/modules/resource/js/resource"
                ],
                stat: [
                    "assets/modules/stat/js/stat"
                ],
                datacount: [
                    "assets/modules/stat/js/datacount"
                ],
                userIndex: [
                    "assets/modules/user/js/userIndex"
                ],
                dvResNodeApplyTab: [
                    "assets/modules/dvResNodeApply/dvResNodeApplyTab"
                ],
                gojs: [
                    "assets/plugins/gojs/go"
                ],
                resInfo: [
                    "assets/modules/dvResConsumerApply/resInfo"
                ],
                malihu: [
                    "assets/plugins/malihu/jquery.mCustomScrollbar.min"
                ],
                mousewheel: [
                    "assets/plugins/malihu/jquery.mousewheel.min"
                ],
                scrollable: [
                    "assets/plugins/jquery-scrollable/scrollable"
                ],
                circleProgress: [
                    "assets/plugins/circle/circle-progress"
                ],
                easing: ["assets/plugins/jquery-carousel/js/jquery.easing.1.3"],
                carousel: ["assets/plugins/jquery-carousel/js/jquery.contentcarousel"],
                tokeninput: ["assets/plugins/jquery-tokeninput/js/jquery.tokeninput"],
                appStatistics: ["assets/modules/appStatistics/appStatistics"],
                starRating:["assets/plugins/bootstrap-star-rating/js/star-rating.min"]
            },
            shim: {
                // Plugins
                bootstrap: {
                    deps: ["jQuery"],
                    exports: "bootstrap"
                },
                jQueryUI: {
                    deps: ["jQuery", "css!assets/plugins/jQueryUI/jquery-ui"],
                    exports: "jQueryUI"
                },
                jQueryBootstrapWizard: {
                    deps: ['jQuery', 'bootstrap', 'validator', "css!assets/plugins/bootstrap-wizard/css/bwizard-steps"],
                    exports: 'jQueryBootstrapWizard'
                },
                angular: {
                    deps: ["jQuery", "bootstrap"],
                    exports: "angular"
                },
                'angular-route': {
                    deps: ["angular"],
                    exports: 'ngRouteModule'
                },
                sanitize: {
                    deps: ["angular", "angular-route"],
                    exports: 'sanitize'
                },
                datepickerZh: {
                    deps: ["datepicker"],
                    exports: "datepickerZh"
                },
                datepicker: {
                    deps: ["jQuery", "bootstrap", "css!assets/plugins/bootstrap-datepicker/css/bootstrap-datepicker3.min"],
                    exports: "datepicker"
                },
                dateRangePicker: {
                    deps: ["jQuery", "bootstrap", "moment", "css!assets/plugins/bootstrap-daterangepicker/daterangepicker"],
                    exports: "dateRangePicker"
                },
                dataTables: {
                    deps: ["jQuery", "bootstrap", "css!assets/plugins/datatables/datatables"],
                    exports: "dataTables"
                },
                switcher: {
                    deps: ["jQuery", "bootstrap", "css!assets/plugins/bootstrap-switch/css/bootstrap3/bootstrap-switch"],
                    exports: "bootstrapSwitch"
                },
                'bootstrap-dialog': {// 插件写死了名称
                    deps: ["jQuery", "bootstrap", "css!assets/plugins/bootstrap-dialog/css/bootstrap-dialog.min"],
                    exports: "dialog"
                },
                validator: {
                    deps: ["jQuery"],
                    exports: "validator"
                },
                bootstrapNotify: {
                    deps: ["jQuery"],
                    exports: "bootstrapNotify"
                },
                jQueryFancyTree: {
                    deps: ["jQuery", "jQueryUI", "css!assets/plugins/fancytree/skin-win8-n/ui.fancytree.min"],
                    exports: "jQueryFancyTree"
                },
                iCheck: {
                    deps: ["jQuery", "css!assets/plugins/iCheck/all.css"],
                    exports: "iCheck"
                },
                select2: {
                    deps: ["jQuery", 'bootstrap', "css!assets/plugins/select2/css/select2.min",
                        "css!assets/modules/core/css/Fusion.css"],
                    exports: "select2"
                },
                inputmask: {
                    deps: ["jQuery"],
                    exports: "inputmask"
                },
                treetable: {
                    deps: ["jQuery", "css!assets/modules/datanode/css/jquery.treetable.datanode", "css!assets/modules/datanode/css/common"],
                    exports: "treetable"
                },
                codemirror: {
                    deps: ["css!assets/plugins/codemirror/codemirror"]
                },
                jsPlumb: {
                    deps: ["jQuery"],
                    exports: "jsPlumb"
                },
                jsPlumbToolkit: {
                    deps: ["jQuery", "jsPlumb", "jQueryUI", "css!assets/plugins/jsPlumb/css/jsPlumbToolkit-defaults"],
                    exports: "jsPlumbToolkit"
                },
                // Modules
                resource: {
                    deps: ['jQuery', 'echarts', 'sparkline', 'css!assets/plugins/ionicons/ionicons.min',
                        "css!assets/modules/datanode/css/datanodeEr", "css!assets/modules/datanode/css/jsPlumbToolkit-datanodeEr",
                        "css!assets/modules/datanode/css/hier", "css!assets/modules/stat/css/stat"],
                    exports: 'resource'
                },
                stat: {
                    deps: ['jQuery', 'echarts', 'sparkline', 'css!assets/plugins/ionicons/ionicons.min',
                        "css!assets/modules/datanode/css/datanodeEr", "css!assets/modules/datanode/css/jsPlumbToolkit-datanodeEr",
                        "css!assets/modules/datanode/css/hier", "css!assets/modules/stat/css/stat"],
                    exports: 'stat'
                },
                datacount: {
                    deps: ['jQuery', 'echarts'],
                    exports: 'datacount'
                },
                echartsTheme: {
                    deps: ['echarts'],
                    exports: 'echartsTheme'
                },
                lineage: {
                    deps: ["jsPlumbToolkit", "css!assets/modules/datanode/css/datanodeEr", "css!assets/modules/datanode/css/jsPlumbToolkit-datanodeEr"],
                    exports: "lineage"
                },
                lineageDb: {
                    deps: ["css!assets/modules/lineage/css/lineage"],
                    exports: "lineageDb"
                },
                ztree: {
                    deps: ['jQuery', "css!assets/plugins/ztree/css/zTreeStyle.css"],
                    exports: 'ztree'
                },
                userIndex: {
                    deps: ['jQuery', 'core'],
                    exports: 'userIndex'
                },
                malihu: {
                    deps: ['jQuery', 'jQueryUI', "mousewheel", "css!assets/plugins/malihu/jquery.mCustomScrollbar"],
                    exports: 'malihu'
                },
                scrollable: {
                    deps: ['jQuery'],
                    exports: 'scrollable'
                },
                carousel: {
                    deps: ['easing', 'mousewheel', "css!assets/plugins/jquery-carousel/css/jquery.jscrollpane", "css!assets/plugins/jquery-carousel/css/style"],
                    exports: 'carousel'
                },
                tokeninput: {
                    deps: ['jQuery', 'css!assets/plugins/jquery-tokeninput/css/token-input-facebook'],
                    exports: 'tokeninput'
                },
                starRating: {
                    deps: ['jQuery', 'css!assets/plugins/bootstrap-star-rating/css/star-rating','css!assets/plugins/bootstrap/css/bootstrap.min','css!assets/plugins/font-awesome/font-awesome.min'],
                    exports: 'starRating'
                }
            }
        })
    }
})();